import org.junit.*;
import static org.junit.Assert.*;

import java.util.Collections;
import java.util.*;



public class testComparable {

	// Planet(int planetID,	int owner,	int numShips,int growthRate,	double x,	double y)	
	
	public Planet p1 = new Planet(1,1,10,5,1,1);
	public Planet p2 = new Planet(2,2,11,6,2,2);
	public Planet p3 = new Planet(3,0,12,7,3,3);
	public Planet p4 = new Planet(4,0,13,8,4,4);
	
	
	public RainmanPlanet rp1 = new RainmanPlanet(p1);
	public RainmanPlanet rp2 = new RainmanPlanet(p2);
	public RainmanPlanet rp3 = new RainmanPlanet(p3);
	public RainmanPlanet rp4 = new RainmanPlanet(p4);
	
	public List<RainmanPlanet> pList = new ArrayList<RainmanPlanet>();
	
	@Before 
	public void setUp(){
		pList.add(rp3);
		pList.add(rp4);
		pList.add(rp2);
		pList.add(rp1);
	}
	
	@Test 
	public void compareGrowth(){
		Collections.sort(pList, new ComparatorGrowth());

		assertEquals(pList.get(0).GrowthRate(), 5);
		assertEquals(pList.get(1).GrowthRate(), 6);
		assertEquals(pList.get(2).GrowthRate(), 7);
		assertEquals(pList.get(3).GrowthRate(), 8);	

		
	}
	
	@Test
	public void comparePayBack(){
		Collections.sort(pList, new ComparatorPayback());
		assertEquals(pList.get(0).payback, (13.0/8.0),0.01);		// 1.62
		assertEquals(pList.get(1).payback, (12.0/7.0),0.01);		// 1.71
		assertEquals(pList.get(2).payback, (11.0/6.0),0.01); 		// 1.83333
		assertEquals(pList.get(3).payback, 2.0,0.01);				// 2.0		

	}
	
}
